package xyz.xiangyushui.controller.manager;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import xyz.xiangyushui.dao.salesPlan.SalesPlanDao;
import xyz.xiangyushui.javaBean.salesPlan.DailyPlan;

/**
 * Servlet implementation class SalesPlanDetail
 */
@WebServlet("/manager/salesPlan")
public class SalesPlanDetail extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private SalesPlanDao spd;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SalesPlanDetail() {
        super();
        spd=new SalesPlanDao();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String planId=request.getParameter("id");
		if(planId==null){
			response.sendError(404);
		}else{
			DailyPlan dp=spd.getDailyPlan(planId, 0);
			if(dp==null){
				response.sendError(404);
			}else{
				request.setAttribute("dailyPlan", dp);
				request.getRequestDispatcher("/manager/approveSalesPlan/detail.jsp").forward(request, response);
			}
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
